#!/bin/bash

DATE=`date '+%S_%M_%H_%d_%m_%y'`

RESULTS_TMP=/tmp/results${RANDOM}_${DATE}

GPUPSAT=../Debug/GPUSATSolver

#$GPUPSAT *.cnf > $RESULTS_TMP

TOTAL_ERRORS=0
TOTAL_TESTS=0

for file in *.cnf
do

	$GPUPSAT 1 $file > $RESULTS_TMP
#	cat $RESULTS_TMP

	while read line
	do
		if [[ $line =~ "There were "[0-9]+" errors out of "[0-9]+" total tests." ]]
		then

			ERRORS=`echo $line | cut -d " " -f 3`
			TOTAL=`echo $line | cut -d " " -f 7`

			if [ $ERRORS -ne "0" ]
			then
				echo "File $file has $ERRORS errors out of ${TOTAL}"
			fi

			let TOTAL_ERRORS+=$ERRORS
			let TOTAL_TESTS+=$TOTAL
		fi

	done <  $RESULTS_TMP

done

echo "Summary:"
echo "There were ${TOTAL_ERRORS} errors out of ${TOTAL_TESTS} tests"

rm $RESULTS_TMP
